<template>
  <!-- 新增处置通讯录 -->
  <h-modal class="event-modal" v-model.lazy="show" name="处置通讯录" @submit="submit">
    <a-form-model ref="ruleForm" :model="form" :rules="rules" size="large">
      <a-row :gutter="100">
        <a-col :span="24">
          <a-form-model-item label="文章地址" prop="link">
            <a-input v-model.lazy="form.link" placeholder="请输入文章地址"></a-input>
          </a-form-model-item>
        </a-col>
      </a-row>

    </a-form-model>
  </h-modal>
</template>

<script>
import moment from 'moment';
import { addMonitorThird } from '@/api/serve';
import cloneDeep from 'lodash/cloneDeep';
// import UploadImageMutil from '@/components/UploadImageMutil';
// import { v4 } from 'uuid';

const defaultForm = {
 link: ''
};

export default {
  props: {
    showModal: {
      type: Boolean,
      default: false
    }
  },
  components: {
    // UploadImageMutil
  },
  model: {
    prop: 'showModal',
    event: 'update:showModal'
  },
  watch: {
    showModal: {
      handler(val) {
        this.show = val;
      },
      immediate: true
    },
    show(val) {
      this.$emit('update:showModal', val);
    },
    dept(val) {
      this.form.departIdList = val.join(',');
    }
  },
  data() {
    return {
      moment,
      type: 'add',
      reload: true,
      show: false,
      deptArr: [],
      dept: [],
      form: cloneDeep(defaultForm),
      rules: {
        link: [{ required: true, message: '请输入' }]
      }
    };
  },
  created() {
  },
  methods: {
    edit(form) {
      // this.type = 'edit';
      // this.form = form;
      // this.form.url = form.img;
      // this.reload = false;
      // this.$nextTick(() => {
      //   this.reload = true;
      // });
    },
    add() {
      this.type = 'add';
      this.form = cloneDeep(defaultForm);
    },
    submit() {
      this.$refs.ruleForm.validate(valid => {
        if (valid) {
          if (this.type == 'add') {
            addMonitorThird(this.form).then(res => {
            this.$message.success('创建成功');
            this.show = false;
            this.$emit('submit', cloneDeep(this.form));
            this.form = cloneDeep(defaultForm);
          });
          }
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    getImg(img) {
      this.$set(this.form, 'img', img);
    }
  }
};
</script>

<style>

</style>
